<?php
$link = @mysql_connect('localhost','root','root');//连接数据库
$errno = mysql_errno();//判断是否连接成功
if(mysql_errno()){
	die("$errno".mysql_error());
}
mysql_select_db('boke');//选择数据库
mysql_set_charset('utf8');//设置字符集
$sql = 'select * from `stu`';//准备SQL语句
$ss = mysql_query($sql);//发送SQL语句
//mysql_fetch_assoc($ss);//处理结果集
$arr=[];
while ($assoc = mysql_fetch_assoc($ss)) {
	
	$arr[] = $assoc;

}
//var_dump($arr);
	mysql_free_result($ss);
	mysql_close($link);

	$str = "<table border=1>";
	$str .=	"<tr>";
	$str .=		"<td>id</td>";
	$str .=		"<td>name</td>";
	$str .=		"<td>sex</td>";
	$str .=		"<td>age</td>";
	$str .=		"<td>classid</td>";
	$str .=	"</tr>";
	foreach ($arr as $v) {
	$str .="<tr>";
	$str .="<td>".$v['id']."</td>";
	$str .="<td>".$v["name"]."</td>";
	$str .="<td>".$v["sex"]."</td>";
	$str .="<td>".$v["age"]."</td>";
	$str .="<td>".$v["classid"]."</td>";
	$str .="<td>"."<a href = delete.php?id={$v['id']}>删除</a>"."</td>";
	$str .="<td>"."<a href = alter1.php?id={$v['id']}&name={$v['name']}&sex={$v['sex']}&age={$v['age']}&classid={$v['classid']}>修改</a>"."</td>";
	$str .="</tr>";
	}
	$str .="<tr>";
	$str .="<td><a href = 'add.html'>添加</a></td>";
	$str .="</tr>";
	$str .="</table>";
	echo $str;


